class Events{

    on(eventName,fn){
        if(typeof(this.listeners[eventName])==="undefined"){
            this.listeners[eventName]=[];
        }
        console.log(this.listeners)
        this.listeners[eventName].push(fn)
    }
    emit(eventName,fn){
        if(typeof(this.listeners[eventName])==="undefined"){
            console.log(eventName+"not exists");
            process.exit();
        }
        this.listeners[eventName].forEach(item => {
            console.log(item)//fn
        });
    }
    listeners={
        
    }
}
let myEvent=new Events();
myEvent.on("test",()=>{
    console.log("this is a test")
})
myEvent.emit("test")